<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ca="http://java.sun.com/jsf/composite/cashSummery"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form id="panelPrint" styleClass="noBorder summeryBorder">

            <p:panel  style="border: none;">
                <f:facet name="header" >
                    <p:outputLabel value="#{creditSummeryController.institution.name} "/> 
                    <p:outputLabel value=" Credit Summary - Detail"/>
                    
                    <h:panelGrid columns="2" >
                        <h:outputLabel value="Credit Company"/>
                        <p:autoComplete styleClass="noPrintButton" id="creditCom" forceSelection="true" value="#{creditSummeryController.institution}" 
                                        completeMethod="#{creditCompanyController.completeCredit}" var="ix" itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;">

                        </p:autoComplete>
                        
                        
                        <h:outputLabel value="Service Name"/>
                        <p:autoComplete value="#{creditSummeryController.item}" completeMethod="#{itemController.completeService}" var="ix" 
                                        itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;" forceSelection="true" >
                            <p:column>
                                #{ix.name}
                            </p:column>
                            <p:column>
                                #{ix.department.name}
                            </p:column>  
                            <p:column>
                                #{ix.category.name}
                            </p:column>
                            
                            <p:column>
                                #{ix.category.parentCategory.name}
                            </p:column> 
                            
                        </p:autoComplete>
                        
                        <h:outputLabel value="From Date"/>
                        <p:calendar id="frmDate" value="#{creditSummeryController.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>

                        <h:outputLabel value="To Date"/>
                        <p:calendar id="toDate" value="#{creditSummeryController.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>
                    </h:panelGrid>
                    <h:panelGrid columns="3" >
                        <p:spacer width="90" height="1"/>
                        <p:commandButton id="btnRefresh" value="Refresh" ajax="false"  
                                         styleClass="noPrintButton" style="float: right;"  action="#{creditSummeryController.createDailyCashTable}"/>
                        <p:commandButton ajax="false" value="Print"  styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="panelPrint" />
                        </p:commandButton>
                    </h:panelGrid>
                </f:facet>

            </p:panel>
            <p:dataGrid  value="#{creditSummeryController.dailyCashSummery}" var="d" columns="1">
                <p:dataTable id="safrin" value="#{d.categoryWitmItems}" var="s" rendered="#{d.departmentTotal!=0}"

                             paginator="false"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15,20">  
                    <f:facet name="header">
                        <h:outputLabel value="REPORT BY ITEM - "/>
                        <h:outputLabel value="#{d.department.name}"/>
                    </f:facet>
                    <p:columnGroup type="header">
                        <p:row>
                            <p:column headerText="Item Name"/>                         
                            <p:column headerText="Count"/>
                            <p:column headerText="Hospital Fee"/>
                            <p:column headerText="Professional Fee"/>
                            <p:column headerText="Total"/>
                        </p:row>
                    </p:columnGroup>
                    <p:subTable value="#{s.itemWithFees}" var="i" rendered="#{s.subTotal!=0}">
                        <f:facet name="header" >
                            <p:outputLabel value="#{s.category.name}" />                                  
                        </f:facet>
                        <p:column>
                            <h:outputLabel value="#{i.item.name}" rendered="#{i.total!=0}" />
                        </p:column>                      
                        <p:column>
                            <h:outputLabel value="#{i.count}" rendered="#{i.total!=0}" />
                        </p:column>
                        <p:column style="text-align: right;" rendered="#{i.total!=0}">                               
                            <h:outputLabel value="#{i.hospitalFee}" style="text-align: right;">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>                                        
                        </p:column>
                        <p:column style="text-align: right;">                               
                            <h:outputLabel value="#{i.proFee}" rendered="#{i.total!=0}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </p:column>
                        <p:column style="text-align: right;">                               
                            <h:outputLabel value="#{i.total}" rendered="#{i.total!=0}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </p:column>

                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column colspan="2">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{s.category.name} Total :"/>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{s.subHosTotal}">
                                            <f:convertNumber pattern="#,##0.00"/>
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{s.subTotal-s.subHosTotal}">
                                            <f:convertNumber pattern="#,##0.00"/>
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{s.subTotal}">
                                            <f:convertNumber pattern="#,##0.00"/>
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>


                    </p:subTable>
                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column colspan="4"  >
                                <f:facet name="footer">
                                    <h:outputLabel value="#{d.department.name} Total :" style="text-align: left;float:left;"/>
                                </f:facet>
                            </p:column>
                            <p:column style="text-align: right;" >
                                <f:facet name="footer">
                                    <h:outputLabel value="#{d.departmentTotal}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                        </p:row>
                    </p:columnGroup>
                </p:dataTable>
                

            </p:dataGrid>
            <p:dataTable id="colCredit"  value="#{creditSummeryController.vatTableOpdCredit}" var="sm">
                <p:column >
                    <h:outputLabel value="#{sm.string}" ></h:outputLabel>
                </p:column>
                <p:column/>
                <p:column/>
                <p:column/>
                <p:column/>
                <p:column style="text-align: right;" >
                    <h:outputLabel value="#{sm.value1}" > 
                        <f:convertNumber pattern="#,##0.00"/>
                    </h:outputLabel>
                </p:column>
            </p:dataTable>

        </h:form>
    </ui:define>


</ui:composition>
